/**
 * Copyright (C) 2011 dinstone <dinstone@163.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.dinstone.faststub.sample.service.impl;

import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.dinstone.faststub.sample.service.IAnotherService;
import com.dinstone.faststub.sample.service.IBusinessService;
import com.dinstone.faststub.sample.service.IOtherService;

public class BusinessService implements IBusinessService {

	private IOtherService otherService;

	private IAnotherService anotherService;

	/**
	 * Description: the otherService to set
	 * 
	 * @param otherService
	 * @see BusinessService#otherService
	 */
	public void setOtherService(IOtherService otherService) {
		this.otherService = otherService;
	}

	public void setAnotherService(IAnotherService anotherService) {
		this.anotherService = anotherService;
	}

	/**
	 * {@inheritDoc}
	 * 
	 */
	public boolean doException(String arg1, int arg2) {
		try {
			anotherService.someAction();
			otherService.returnException(arg1, arg2);
		} catch (IOException e) {
			return false;
		}

		return true;
	}

	/**
	 * {@inheritDoc}
	 * 
	 */
	public List<String> doList(String arg1, int arg2) {
		anotherService.someAction();
		List<String> res = otherService.returnList(arg1, arg2);
		return res;

	}

	/**
	 * {@inheritDoc}
	 */
	public Set<String> doSet(String arg1, int arg2) {
		anotherService.someAction();
		Set<String> set = otherService.returnSet(arg1, arg2);
		return set;
	}

	/**
	 * {@inheritDoc}
	 */
	public Map<String, String> doMap(String arg1, int arg2) {
		anotherService.someAction();
		Map<String, String> map = otherService.returnMap(arg1, arg2);
		return map;
	}

	/**
	 * {@inheritDoc}
	 */
	public String doString(String arg1, int arg2) {
		anotherService.someAction();
		String str = otherService.returnString(arg1, arg2);
		return str;
	}

	/**
	 * {@inheritDoc}
	 */
	public int doInteger(String arg1, int arg2) {
		anotherService.someAction();
		int i = otherService.returnInteger(arg1, arg2);
		return i;
	}

	/**
	 * {@inheritDoc}
	 */
	public char doChar(String arg1, int arg2) {
		anotherService.someAction();
		char chara = otherService.returnChar(arg1, arg2);
		return chara;
	}

	/**
	 * {@inheritDoc}
	 * 
	 */
	public String[] doArray(String arg1, int arg2) {
		anotherService.someAction();
		String[] arr = otherService.returnArray(arg1, arg2);
		return arr;
	}

	public Date doDate(String arg1, int arg2) {
		anotherService.someAction();
		return otherService.returnDate(arg1, arg2);
	}

}
